package kr.hkit.PowerJava.chapter24;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyFileStream {
 public static void main(String[] args) {
	   FileInputStream fis = null;
	   FileOutputStream fos = null;
	   try {
		fis = new FileInputStream("input.txt");
	    fos = new FileOutputStream("output.txt",false);
		int c;
	    while( (c = fis.read()) != -1){
	   // 	System.out.printf("%s", (char)c);
	    	fos.write(c);
	    }
		System.out.println("파일존재");
	   } catch (FileNotFoundException e) {
      System.err.format("%s%n","파일이 존재하지 않음");
      } catch (IOException e) {
		e.printStackTrace();
	}finally{
    	  if(fis != null){
    		  try{fis.close();}catch(Exception e){}
    	  }
    	  if (fos != null){
    		  try{fos.close();}catch(Exception e){}
    	  }
      }
}
}
